﻿@inherits BaseComponent

<div class="kui-file-view">
    <div class="items">
        @if (Items == null || Items.Count == 0)
        {
            <Empty />
        }
        else
        {
            foreach (var item in Items)
            {
                var className = item.Id == current?.Id ? "kui-link active" : "kui-link";
                <span class="@className" @onclick="e=>OnFileClick(item)">@item.Name</span>
            }
        }
    </div>
    <div class="view">
        @if (Utils.CheckImage(current?.SourceName))
        {
            <img src="@current?.FileUrl?.OriginalUrl" />
        }
        else if (current?.SourceName.EndsWith(".pdf") == true)
        {
            var pdfId = $"pdfView-{current?.Id}";
            <div id="@pdfId" style="width:100%;height:100%;" />
        }
        else
        {
            <Empty>
                <DescriptionTemplate>
                    <span>@Language[Language.TipNotPreview]</span>
                </DescriptionTemplate>
                <ChildContent>
                    @if (Config.App.Type != AppType.Web) {
                        <KButton Type="ButtonType.Primary" Name="@Language.Download" OnClick="OnDownload" />
                    } else {
                        <a class="ant-btn ant-btn-primary" href="@current?.FileUrl?.OriginalUrl" download="@current?.FileUrl?.FileName" target="_blank">@Language[Language.Download]</a>
                    }
                </ChildContent>
            </Empty>
        }
    </div>
</div>